package com.ggambo.HandCoin.Advertising;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.ggambo.HandCoin.R;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: com
 * Date: 13. 1. 7
 * Time: 오후 10:16
 * To change this template use File | Settings | File Templates.
 */
public class Advertising_Adapter extends ArrayAdapter<Advertising>
{
    private Context mContext;
    private ArrayList<Advertising> ad_list;
    private LayoutInflater mInflater;

    public Advertising_Adapter(Context context, int textViewResourceId, ArrayList<Advertising> items)
    {
        super(context, textViewResourceId, items);
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.mContext = context;
        this.ad_list = items;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        if(convertView == null)
        {
            convertView = mInflater.inflate(R.layout.advertising , null);
        }
        Advertising advertising = ad_list.get(position);

        if(advertising != null)
        {
            TextView tv1 = (TextView) convertView.findViewById(R.id.ad_price);
            TextView tv2 = (TextView) convertView.findViewById(R.id.ad_name);
            TextView tv3 = (TextView) convertView.findViewById(R.id.ad_explanation);

            tv1.setText(advertising.get_Ad_price());
            tv2.setText(advertising.get_Ad_name());
            tv3.setText(advertising.get_Ad_explanation());

            ImageView iv = (ImageView) convertView.findViewById(R.id.ad_image);



            iv.setImageResource(advertising.get_Ad_image());
        }
        return convertView;
    }



}
